package com.wutuo.classroom.provider.base;


import com.wutuo.classroom.provider.domain.LearningClassroom;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * 学堂 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

public class BaseLearningClassroomSqlProvider implements java.io.Serializable {

    public String insertSelective(LearningClassroom record) {

        BEGIN();
        INSERT_INTO("learning_classroom");
        insertKey(record);
        return SQL();
    }

    public void insertKey(LearningClassroom record) {

        if (record.getUserId() != null) {
            VALUES("user_id", "#{userId,jdbcType=BIGINT}");
        }
        if (record.getCmInstitutionId() != null) {
            VALUES("cm_institution_id", "#{cmInstitutionId,jdbcType=BIGINT}");
        }
        if (record.getLearningTitle() != null) {
            VALUES("learning_title", "#{learningTitle,jdbcType=VARCHAR}");
        }
        if (record.getLearningObject() != null) {
            VALUES("learning_object", "#{learningObject,jdbcType=VARCHAR}");
        }
        if (record.getTeacher() != null) {
            VALUES("teacher", "#{teacher,jdbcType=VARCHAR}");
        }
        if (record.getInstitution() != null) {
            VALUES("institution", "#{institution,jdbcType=VARCHAR}");
        }
        if (record.getLearningPhoto() != null) {
            VALUES("learning_photo", "#{learningPhoto,jdbcType=VARCHAR}");
        }
        if (record.getPageNum() != null) {
            VALUES("page_num", "#{pageNum,jdbcType=BIGINT}");
        }
        if (record.getRecommendedIndex() != null) {
            VALUES("recommended_index", "#{recommendedIndex,jdbcType=VARCHAR}");
        }
        if (record.getCreateBy() != null) {
            VALUES("create_by", "#{createBy,jdbcType=BIGINT}");
        }
        if (record.getLearningPdf() != null) {
            VALUES("learning_pdf", "#{learningPdf,jdbcType=VARCHAR}");
        }
        if (record.getLearningImage() != null) {
            VALUES("learning_image", "#{learningImage,jdbcType=VARCHAR}");
        }
        if (record.getLearningOffice() != null) {
            VALUES("learning_office", "#{learningOffice,jdbcType=VARCHAR}");
        }
        if (record.getCreateDate() != null) {
            VALUES("create_date", "#{createDate,jdbcType=VARCHAR}");
        }
        if (record.getUpdateBy() != null) {
            VALUES("update_by", "#{updateBy,jdbcType=BIGINT}");
        }
        if (record.getUpdateDate() != null) {
            VALUES("update_date", "#{updateDate,jdbcType=VARCHAR}");
        }
        if (record.getRemarks() != null) {
            VALUES("remarks", "#{remarks,jdbcType=VARCHAR}");
        }
        if (record.getDelFlag() != null) {
            VALUES("del_flag", "#{delFlag,jdbcType=VARCHAR}");
        }
        if (record.getYear() != null) {
            VALUES("year", "#{year,jdbcType=BIGINT}");
        }
        if (record.getState() != null) {
            VALUES("state", "#{state,jdbcType=VARCHAR}");
        }
        if (record.getLearningType() != null) {
            VALUES("learning_type", "#{learningType,jdbcType=VARCHAR}");
        }
    }

    public String updateByPrimaryKeySelective(LearningClassroom record) {

        BEGIN();
        UPDATE("learning_classroom");
        updateKey(record);
        WHERE("id = #{id,jdbcType=BIGINT}");
        return SQL();
    }

    public void updateKey(LearningClassroom record) {

        if (record.getId() != null) {
            SET("id = #{id,jdbcType=BIGINT}");
        }
        if (record.getUserId() != null) {
            SET("user_id = #{userId,jdbcType=BIGINT}");
        }
        if (record.getCmInstitutionId() != null) {
            SET("cm_institution_id = #{cmInstitutionId,jdbcType=BIGINT}");
        }
        if (record.getLearningTitle() != null) {
            SET("learning_title = #{learningTitle,jdbcType=VARCHAR}");
        }
        if (record.getLearningObject() != null) {
            SET("learning_object = #{learningObject,jdbcType=VARCHAR}");
        }
        if (record.getTeacher() != null) {
            SET("teacher = #{teacher,jdbcType=VARCHAR}");
        }
        if (record.getInstitution() != null) {
            SET("institution = #{institution,jdbcType=VARCHAR}");
        }
        if (record.getLearningPhoto() != null) {
            SET("learning_photo = #{learningPhoto,jdbcType=VARCHAR}");
        }
        if (record.getPageNum() != null) {
            SET("page_num = #{pageNum,jdbcType=BIGINT}");
        }
        if (record.getRecommendedIndex() != null) {
            SET("recommended_index = #{recommendedIndex,jdbcType=VARCHAR}");
        }
        if (record.getCreateBy() != null) {
            SET("create_by = #{createBy,jdbcType=BIGINT}");
        }
        if (record.getLearningPdf() != null) {
            SET("learning_pdf = #{learningPdf,jdbcType=VARCHAR}");
        }
        if (record.getLearningImage() != null) {
            SET("learning_image = #{learningImage,jdbcType=VARCHAR}");
        }
        if (record.getLearningOffice() != null) {
            SET("learning_office = #{learningOffice,jdbcType=VARCHAR}");
        }
        if (record.getCreateDate() != null) {
            SET("create_date = #{createDate,jdbcType=VARCHAR}");
        }
        if (record.getUpdateBy() != null) {
            SET("update_by = #{updateBy,jdbcType=BIGINT}");
        }
        if (record.getUpdateDate() != null) {
            SET("update_date = #{updateDate,jdbcType=VARCHAR}");
        }
        if (record.getRemarks() != null) {
            SET("remarks = #{remarks,jdbcType=VARCHAR}");
        }
        if (record.getDelFlag() != null) {
            SET("del_flag = #{delFlag,jdbcType=VARCHAR}");
        }
        if (record.getYear() != null) {
            SET("year = #{year,jdbcType=BIGINT}");
        }
        if (record.getState() != null) {
            SET("state = #{state,jdbcType=VARCHAR}");
        }
        if (record.getState() != null) {
            SET("learning_type = #{learningType,jdbcType=VARCHAR}");
        }
    }
}